ALTER TABLE voucher_trade
ADD cPINo VARCHAR(20) NULL
--------------------------------
DECLARE 
	@cTranNo VARCHAR(25),
	@cWRRPINo VARCHAR(18)

DECLARE table_cursor CURSOR FOR
	SELECT cTranNo,cWRRNo FROM voucher_trade
OPEN table_cursor  
FETCH next FROM table_cursor INTO @cTranNo,@cWRRPINo

WHILE @@fetch_status = 0
	BEGIN 
		UPDATE voucher_trade SET cPINo = @cWRRPINo WHERE cTranNo = @cTranNo
		FETCH next FROM table_cursor INTO @cTranNo,@cWRRPINo
	END

CLOSE table_cursor  
DEALLOCATE table_cursor 

--------------------------------
ALTER TABLE voucher_trade
DROP COLUMN cWRRNo

SELECT DISTINCT cParamName FROM PARAMETER_USER WHERE cType = 'ITEMUNIT'

UPDATE so SET lPApproved = 0,
    lCApproved = 0 WHERE cSONo = '1584' AND cCompanyID = '100-00'